<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>重定向，别名</title>
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
    <script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>
</head>
<body>
    <div id="app">
        <router-view></router-view>
    </div>
    <script>
        const MyOne={template:`<div>组件一</div>`};
        const MyTwo={template:`<div>组件二</div>`};
        const NotFound = {
        template:`<div>页面不存在</div>`
    }
        const routes = [
            {
                path:"/one",
                component:MyOne,
                // 组件一的别名，访问one或alias就是组件MyOne的内容
                alias:"/nickname"
            },
            {
                path:"/two",
                component:MyTwo,
                name:"two"
            },
            {
                path:"/three",
                redirect:"/one"
            },
            {
                path:"/",
                redirect:"/one"
            },
            {
                path:"*",
                component:NotFound,
            }
        ];

        const router = new VueRouter({
            routes,
        })

        const app = new Vue({
            el:"#app",
            router,
        })
    </script>
</body>
</html>